package com.poi;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class FileUtil {

	public static void main(String[] args) {
		String value = "b:5,7";
//		String aa = value.charAt(0);
//		System.out.println(line);
		//test("insert into fld (sys, tabname, colname, namee, namec, isnum, disporder, disptype, newedit, editable, nullable, disprows, minval, maxval, defval, groupc, groupe, iscard) values(0,'xyfsjllxcjcjlb_zb', 'dxdm',   'dxdm',   '地形地貌', 0,       7,        2,      1,          1,      1,        1, '', '', '', '', '',0);");
//		executeAssetsSQL("C:\\Users\\zhengchaojun\\Desktop\\代办事项\\自然资源数据库相关\\test.sql");
	}

	public static void executeAssetsSQL(String path) {
		BufferedReader in = null;
		String line = null;
		try {
			in = new BufferedReader(new FileReader(new File(path)));
			while ((line = in.readLine()) != null) {

				if (line.trim().endsWith(";")) {
					String sql = line;
					fy(sql);
				} else {
					System.out.println(line);
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}


	/**
	 * 翻译成英文
	 * @param name
	 */
	public static void fy(String name) {
		int lenagth = name.lastIndexOf(",");
		String name2 = name.substring(0, lenagth);
		name = name.substring(lenagth);
		int position = name.indexOf("'");
		int lastPosition = name.lastIndexOf("'");
		name = name.substring(position+1, lastPosition);


		try {
//			System.out.println(name2+", '"+PinYinUtil.toFirstCharUpCase(name)+"');");
		} catch (Exception e) {
			System.out.println(name2);
		}
	}

	/**
	 * 获取values后面的值然后截取
	 * @param name 举例：insert into fld (sys, tabname, colname, namee, namec, isnum, disporder, disptype, newedit, editable, nullable, disprows, minval, maxval, defval, groupc, groupe, iscard) values(0,'xyfsjllxcjcjlb_zb', 'dxdm',   'dxdm',   '地形地貌', 0,       7,        2,      1,          1,      1,        1, '', '', '', '', '',0);
	 */
	public static void test(String name) {
		String[] splitte =name.split(",");
		int lenagth = name.indexOf(splitte[27]);

//		System.out.println(lenagth);

		name = name.substring(0, lenagth);

		name = name.replaceFirst(splitte[27], "0");

		System.out.println(name);

	}

}
